<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: Spec - howl.ui.Editor</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_spec doc_spec_ui doc_spec_ui_editor_spec'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl 0.3 Documentation</a></li><li>Spec</li><li>Ui</li><li>Spec - howl.ui.Editor</li></ol>
      <div class="spec-group spec-group-1">&#x000A;&#x000A;<h1 id="howl.ui.editor">howl.ui.Editor</h1>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="kd">local</span><span class="w"> </span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="n">lines</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Editor</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">window</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">OffscreenWindow</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">window</span><span class="o">\</span><span class="n">add</span><span class="w"> </span><span class="n">editor</span><span class="o">\</span><span class="n">to_gobject</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">window</span><span class="o">\</span><span class="n">show_all</span><span class="o">!</span><span class="w">&#x000A;&#x000A;</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;  </span><span class="n">lines</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">lines</span><span class="w">&#x000A;  </span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="w">&#x000A;  </span><span class="n">selection</span><span class="o">\</span><span class="n">remove</span><span class="o">!</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".current_line-is-a-shortcut-for-the-current-buffer-line">.current_line is a shortcut for the current buffer line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">current_line</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">lines</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".current_context-returns-the-buffer-context-at-the-current-position">.current_context returns the buffer context at the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nwʘrld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">context</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">current_context</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'Context'</span><span class="p">,</span><span class="w"> </span><span class="n">typeof</span><span class="w"> </span><span class="n">context</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">context</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".newline()-adds-a-newline-at-the-current-position">.newline() adds a newline at the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">newline</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏ\nllo'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="insert(text)-inserts-the-text-at-the-cursor,-and-moves-cursor-after-text">insert(text) inserts the text at the cursor, and moves cursor after text</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="s1">' world'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo world'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">12</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">12</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="delete_line()-deletes-the-current-line">delete_line() deletes the current line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_line</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'world!'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="copy_line()-copies-the-current-line">copy_line() copies the current line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\n'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">copy_line</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo\nhƏllo\n'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="join_lines-joins-the-current-line-with-the-one-after">join_lines joins the current line with the one after</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\n    world!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">join_lines</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo world!'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="forward_to_match(string)-moves-the-cursor-to-next-occurence-of-&lt;string&gt;,-if-found-in-the-line">forward_to_match(string) moves the cursor to next occurence of &lt;string&gt;, if found in the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏll\to\n    world!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">forward_to_match</span><span class="w"> </span><span class="s1">'l'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">forward_to_match</span><span class="w"> </span><span class="s1">'l'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">forward_to_match</span><span class="w"> </span><span class="s1">'o'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">forward_to_match</span><span class="w"> </span><span class="s1">'w'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="backward_to_match(string)-moves-the-cursor-back-to-previous-occurence-of-&lt;string&gt;,-if-found-in-the-line">backward_to_match(string) moves the cursor back to previous occurence of &lt;string&gt;, if found in the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'h\tƏllo\n    world!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">backward_to_match</span><span class="w"> </span><span class="s1">'l'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">backward_to_match</span><span class="w"> </span><span class="s1">'l'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">backward_to_match</span><span class="w"> </span><span class="s1">'h'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">backward_to_match</span><span class="w"> </span><span class="s1">'w'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".active_lines">.active_lines</h2>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with no selection active)</span></h3>&#x000A;&#x000A;<h4 id="is-a-table-containing-.current_line">is a table containing .current_line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">lines</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">active_lines</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="o">#</span><span class="n">lines</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">current_line</span><span class="p">,</span><span class="w"> </span><span class="n">lines</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with a selection active)</span></h3>&#x000A;&#x000A;<h4 id="is-a-table-of-lines-involved-in-the-selection">is a table of lines involved in the selection</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">8</span><span class="w">&#x000A;</span><span class="n">active_lines</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">active_lines</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="o">#</span><span class="n">active_lines</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="n">lines</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="w"> </span><span class="n">active_lines</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="n">lines</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span><span class="w"> </span><span class="n">active_lines</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".active_chunk">.active_chunk</h2>&#x000A;&#x000A;<h4 id="is-a-chunk">is a chunk</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Chunk'</span><span class="p">,</span><span class="w"> </span><span class="n">typeof</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">active_chunk</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with no selection active)</span></h3>&#x000A;&#x000A;<h4 id="is-a-chunk-encompassing-the-entire-buffer-text">is a chunk encompassing the entire buffer text</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">active_chunk</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with a selection active)</span></h3>&#x000A;&#x000A;<h4 id="is-a-chunk-containing-the-current-the-selection">is a chunk containing the current the selection</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">8</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'llo\nw'</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">active_chunk</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="indent">indent<span class="arg-list">()</span></h3>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode does not provide a indent method)</span></h3>&#x000A;&#x000A;<h4 id="does-nothing">does nothing</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode provides a indent method)</span></h3>&#x000A;&#x000A;<h4 id="calls-that-passing-itself-a-parameter">calls that passing itself a parameter</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">method</span><span class="p">]:</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">[</span><span class="n">method</span><span class="p">]).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="comment">comment<span class="arg-list">()</span></h3>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode does not provide a comment method)</span></h3>&#x000A;&#x000A;<h4 id="does-nothing">does nothing</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode provides a comment method)</span></h3>&#x000A;&#x000A;<h4 id="calls-that-passing-itself-a-parameter">calls that passing itself a parameter</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">method</span><span class="p">]:</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">[</span><span class="n">method</span><span class="p">]).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="uncomment">uncomment<span class="arg-list">()</span></h3>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode does not provide a uncomment method)</span></h3>&#x000A;&#x000A;<h4 id="does-nothing">does nothing</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode provides a uncomment method)</span></h3>&#x000A;&#x000A;<h4 id="calls-that-passing-itself-a-parameter">calls that passing itself a parameter</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">method</span><span class="p">]:</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">[</span><span class="n">method</span><span class="p">]).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="toggle_comment">toggle_comment<span class="arg-list">()</span></h3>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode does not provide a toggle_comment method)</span></h3>&#x000A;&#x000A;<h4 id="does-nothing">does nothing</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when mode provides a toggle_comment method)</span></h3>&#x000A;&#x000A;<h4 id="calls-that-passing-itself-a-parameter">calls that passing itself a parameter</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">method</span><span class="p">]:</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">[</span><span class="n">method</span><span class="p">]</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">[</span><span class="n">method</span><span class="p">]).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="with_position_restored">with_position_restored<span class="arg-list">(f)</span></h2>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  yowser!\n  yikes!'</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="calls-&lt;f&gt;-passing-itself-a-parameter">calls &lt;f&gt; passing itself a parameter</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">f</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">with_position_restored</span><span class="w"> </span><span class="n">f</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">f</span><span class="p">).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="restores-the-cursor-position-afterwards">restores the cursor position afterwards</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">editor</span><span class="o">\</span><span class="n">with_position_restored</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="adjusts-the-position-should-the-indentation-have-changed">adjusts the position should the indentation have changed</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">editor</span><span class="o">\</span><span class="n">with_position_restored</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">lines</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="n">indentation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w">&#x000A;  </span><span class="n">lines</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">indentation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w">&#x000A;&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w">&#x000A;&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">with_position_restored</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">lines</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="n">indentation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;  </span><span class="n">lines</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">indentation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when &lt;f&gt; raises an error)</span></h3>&#x000A;&#x000A;<h4 id="propagates-the-error">propagates the error</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">raises</span><span class="w"> </span><span class="s1">'ARGH!'</span><span class="p">,</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">editor</span><span class="o">\</span><span class="n">with_position_restored</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="nb">error</span><span class="w"> </span><span class="s1">'ARGH!'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="the-position-is-still-restored">the position is still restored</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;&#x000A;</span><span class="nb">pcall</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">with_position_restored</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span><span class="p">,</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;  </span><span class="nb">error</span><span class="w"> </span><span class="s1">'ARGH!'</span><span class="w">&#x000A;&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="paste">paste<span class="arg-list">(opts = {})</span></h2>&#x000A;&#x000A;<h4 id="pastes-the-current-clip-of-the-clipboard-at-the-current-position">pastes the current clip of the clipboard at the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="s1">' wörld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo wörld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when opts.clip is specified)</span></h3>&#x000A;&#x000A;<h4 id="pastes-that-clip-at-the-current-position">pastes that clip at the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="s1">'hello'</span><span class="w">&#x000A;</span><span class="n">clip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">clipboard</span><span class="p">.</span><span class="n">current</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="s1">'wörld'</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'well '</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="w"> </span><span class="ss">:clip</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'well hello'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when opts.where is set to &quot;after&quot;)</span></h3>&#x000A;&#x000A;<h4 id="pastes-the-clip-to-the-right-of-the-current-position">pastes the clip to the right of the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\n'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="s1">'yo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="w"> </span><span class="ss">where:</span><span class="w"> </span><span class="s1">'after'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo yo\n'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="w"> </span><span class="ss">where:</span><span class="w"> </span><span class="s1">'after'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo yo\n yo'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when the clip item has .whole_lines set)</span></h3>&#x000A;&#x000A;<h4 id="pastes-the-clip-on-a-newly-opened-line-above-the-current">pastes the clip on a newly opened line above the current</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="ss">text:</span><span class="w"> </span><span class="s1">'cruel'</span><span class="p">,</span><span class="w"> </span><span class="ss">whole_lines:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo\ncruel\nworld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="pastes-the-clip-at-the-start-of-a-line-if-ends-with-a-newline-separator">pastes the clip at the start of a line if ends with a newline separator</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="ss">text:</span><span class="w"> </span><span class="s1">'cruel\n'</span><span class="p">,</span><span class="w"> </span><span class="ss">whole_lines:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo\ncruel\nworld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="positions-the-cursor-at-the-start-of-the-pasted-clip">positions the cursor at the start of the pasted clip</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'paste'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="ss">text:</span><span class="w"> </span><span class="s1">'much'</span><span class="p">,</span><span class="w"> </span><span class="ss">whole_lines:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(..  when opts.where is set to &quot;after&quot;)</span></h3>&#x000A;&#x000A;<h4 id="pastes-the-clip-on-a-newly-opened-line-below-the-current">pastes the clip on a newly opened line below the current</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="ss">text:</span><span class="w"> </span><span class="s1">'cruel'</span><span class="p">,</span><span class="w"> </span><span class="ss">whole_lines:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="w"> </span><span class="ss">where:</span><span class="w"> </span><span class="s1">'after'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo\ncruel\nworld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when a selection is present)</span></h3>&#x000A;&#x000A;<h4 id="deletes-the-selection-before-pasting">deletes the selection before pasting</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nwonderful\nworld'</span><span class="w">&#x000A;</span><span class="n">clipboard</span><span class="p">.</span><span class="n">push</span><span class="w"> </span><span class="ss">text:</span><span class="w"> </span><span class="s1">'cruel'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="nb">select</span><span class="w"> </span><span class="n">lines</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">start_pos</span><span class="p">,</span><span class="w"> </span><span class="n">lines</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">end_pos</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo\ncruel\nworld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'cruel'</span><span class="p">,</span><span class="w"> </span><span class="n">clipboard</span><span class="p">.</span><span class="n">current</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="delete_to_end_of_line">delete_to_end_of_line<span class="arg-list">(no_copy)</span></h2>&#x000A;&#x000A;<h4 id="cuts-text-from-cursor-up-to-end-of-line">cuts text from cursor up to end of line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo world!\nnext'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_to_end_of_line</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏllo\nnext'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏllo world!\nnext'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="deletes-without-copying-if-no_copy-is-specified">deletes without copying if no_copy is specified</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo world!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_to_end_of_line</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏ'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">paste</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">not_equal</span><span class="w"> </span><span class="s1">'hƏllo world!'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(buffer switching)</span></h3>&#x000A;&#x000A;<h4 id="remembers-the-position-for-different-buffers">remembers the position for different buffers</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\n    world!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span><span class="w">&#x000A;</span><span class="n">buffer2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">buffer2</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'a whole different whale'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">15</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buffer2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">15</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="updates-.last_shown-for-buffer-switched-out">updates .last_shown for buffer switched out</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">os.time</span><span class="w">&#x000A;</span><span class="n">now</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">time</span><span class="o">!</span><span class="w">&#x000A;</span><span class="nb">os.time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">now</span><span class="w">&#x000A;</span><span class="nb">pcall</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="nb">os.time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">time</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="n">now</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">last_shown</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(previewing)</span></h3>&#x000A;&#x000A;<h4 id="does-not-update-last_shown-for-previewed-buffer">does not update last_shown for previewed buffer</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">new_buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">new_buffer</span><span class="p">.</span><span class="n">last_shown</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">preview</span><span class="w"> </span><span class="n">new_buffer</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">new_buffer</span><span class="p">.</span><span class="n">last_shown</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="updates-.last_shown-for-original-buffer-switched-out">updates .last_shown for original buffer switched out</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">os.time</span><span class="w">&#x000A;</span><span class="n">now</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">time</span><span class="o">!</span><span class="w">&#x000A;</span><span class="nb">os.time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">now</span><span class="w">&#x000A;</span><span class="nb">pcall</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">editor</span><span class="o">\</span><span class="n">preview</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="nb">os.time</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">time</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">same</span><span class="w"> </span><span class="n">now</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">last_shown</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(indentation, tabs, spaces and backspace)</span></h3>&#x000A;&#x000A;<h4 id="defines-a-&quot;tab_width&quot;-config-variable,-defaulting-to-8">defines a &quot;tab_width&quot; config variable, defaulting to 8</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="defines-a-&quot;use_tabs&quot;-config-variable,-defaulting-to-false">defines a &quot;use_tabs&quot; config variable, defaulting to false</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">use_tabs</span><span class="p">,</span><span class="w"> </span><span class="kc">false</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="defines-a-&quot;indent&quot;-config-variable,-defaulting-to-2">defines a &quot;indent&quot; config variable, defaulting to 2</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="defines-a-&quot;tab_indents&quot;-config-variable,-defaulting-to-true">defines a &quot;tab_indents&quot; config variable, defaulting to true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">tab_indents</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="defines-a-&quot;backspace_unindents&quot;-config-variable,-defaulting-to-true">defines a &quot;backspace_unindents&quot; config variable, defaulting to true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">backspace_unindents</span><span class="p">,</span><span class="w"> </span><span class="kc">true</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="smart_tab">smart_tab<span class="arg-list">()</span></h3>&#x000A;&#x000A;<h4 id="inserts-a-tab-character-if-use_tabs-is-true">inserts a tab character if use_tabs is true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">use_tabs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">smart_tab</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'h\tƏllo'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="inserts-spaces-to-move-to-the-next-tab-if-use_tabs-is-false">inserts spaces to move to the next tab if use_tabs is false</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">use_tabs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">smart_tab</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="nb">string.rep</span><span class="p">(</span><span class="s1">' '</span><span class="p">,</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="p">)</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="inserts-a-tab-to-move-to-the-next-tab-stop-if-use_tabs-is-true">inserts a tab to move to the next tab stop if use_tabs is true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">use_tabs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">smart_tab</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'\thƏllo'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="indents-the-current-line-if-in-whitespace-and-tab_indents-is-true">indents the current line if in whitespace and tab_indents is true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">use_tabs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="w">&#x000A;</span><span class="n">config</span><span class="p">.</span><span class="n">tab_indents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">string.rep</span><span class="w"> </span><span class="s1">' '</span><span class="p">,</span><span class="w"> </span><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">indent</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">smart_tab</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="nb">string.rep</span><span class="p">(</span><span class="n">indent</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="s1">'hƏllo'</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=".delete_back">.delete_back<span class="arg-list">()</span></h3>&#x000A;&#x000A;<h4 id="deletes-back-by-one-character">deletes back by one character</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_back</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'Əllo'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="unindents-if-in-whitespace-and-backspace_unindents-is-true">unindents if in whitespace and backspace_unindents is true</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">config</span><span class="p">.</span><span class="n">backspace_unindents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_back</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏllo'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="deletes-back-if-in-whitespace-and-backspace_unindents-is-false">deletes back if in whitespace and backspace_unindents is false</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">config</span><span class="p">.</span><span class="n">backspace_unindents</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_back</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">' hƏllo'</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=".delete_forward">.delete_forward<span class="arg-list">()</span></h3>&#x000A;&#x000A;<h4 id="deletes-the-character-at-cursor">deletes the character at cursor</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_forward</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hllo'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when a selection is active)</span></h3>&#x000A;&#x000A;<h4 id="deletes-the-selection">deletes the selection</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_forward</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'ho'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">not_equal</span><span class="w"> </span><span class="s1">'Əll'</span><span class="p">,</span><span class="w"> </span><span class="n">clipboard</span><span class="p">.</span><span class="n">current</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when at the end of a line)</span></h3>&#x000A;&#x000A;<h4 id="deletes-the-line-break">deletes the line break</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_forward</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏlloworld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-4">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when at the end of the buffer)</span></h3>&#x000A;&#x000A;<h4 id="does-nothing">does nothing</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">delete_forward</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=".shift_right">.shift_right<span class="arg-list">()</span></h3>&#x000A;&#x000A;<h4 id="right-shifts-the-lines-included-in-a-selection-if-any">right-shifts the lines included in a selection if any</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nselected\nworld!'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">shift_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'  hƏllo\n  selected\nworld!'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="right-shifts-the-current-line-when-nothing-is-selected,-remembering-column">right-shifts the current line when nothing is selected, remembering column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏllo\nworld!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">shift_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'  hƏllo\nworld!'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=".shift_left">.shift_left<span class="arg-list">()</span></h3>&#x000A;&#x000A;<h4 id="left-shifts-the-lines-included-in-a-selection-if-any">left-shifts the lines included in a selection if any</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  hƏllo\n  selected\nworld!'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">12</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">shift_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hƏllo\nselected\nworld!'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="left-shifts-the-current-line-when-nothing-is-selected,-remembering-column">left-shifts the current line when nothing is selected, remembering column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">config</span><span class="p">.</span><span class="n">indent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'    hƏllo\nworld!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">shift_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'  hƏllo\nworld!'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(events)</span></h3>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="on-char-added">on char added</h3>&#x000A;&#x000A;<h4 id="emits-a-character-added-event-with-the-passed-arguments-merged-with-the-editor-reference">emits a character-added event with the passed arguments merged with the editor reference</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">handler</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">signal</span><span class="p">.</span><span class="n">connect</span><span class="w"> </span><span class="s1">'character-added'</span><span class="p">,</span><span class="w"> </span><span class="n">handler</span><span class="w">&#x000A;</span><span class="n">args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ss">key_name:</span><span class="w"> </span><span class="s1">'a'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">_on_char_added</span><span class="w"> </span><span class="n">args</span><span class="w">&#x000A;</span><span class="n">signal</span><span class="p">.</span><span class="n">disconnect</span><span class="w"> </span><span class="s1">'character-added'</span><span class="p">,</span><span class="w"> </span><span class="n">handler</span><span class="w">&#x000A;</span><span class="n">args</span><span class="p">.</span><span class="n">editor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">handler</span><span class="p">).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">args</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="invokes-mode.on_char_added-if-present,-passing-(arguments,-editor)">invokes mode.on_char_added if present, passing (arguments, editor)</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ss">on_char_added:</span><span class="w"> </span><span class="n">spy</span><span class="p">.</span><span class="n">new</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="n">args</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ss">key_name:</span><span class="w"> </span><span class="s1">'a'</span><span class="p">,</span><span class="w"> </span><span class="ss">:editor</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">_on_char_added</span><span class="w"> </span><span class="n">args</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">spy</span><span class="p">(</span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">.</span><span class="n">on_char_added</span><span class="p">).</span><span class="n">was_called_with</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">mode</span><span class="p">,</span><span class="w"> </span><span class="n">args</span><span class="p">,</span><span class="w"> </span><span class="n">editor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(resource management)</span></h3>&#x000A;&#x000A;<h4 id="editors-are-collected-as-they-should">editors are collected as they should</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">e</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Editor</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">editors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">setmetatable</span><span class="w"> </span><span class="p">{},</span><span class="w"> </span><span class="ss">__mode:</span><span class="w"> </span><span class="s1">'v'</span><span class="w">&#x000A;</span><span class="n">append</span><span class="w"> </span><span class="n">editors</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="w">&#x000A;</span><span class="n">e</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">nil</span><span class="w">&#x000A;</span><span class="nb">collectgarbage</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="n">editors</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="cycle_case">cycle_case<span class="arg-list">()</span></h2>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with a selection active)</span></h3>&#x000A;&#x000A;<h4 id="changes-all-lowercase-selection-to-all-uppercase">changes all lowercase selection to all uppercase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello selectëd #world'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">22</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello SELECTËD #WORLD'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="changes-all-uppercase-selection-to-titlecase">changes all uppercase selection to titlecase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello SELECTËD #WORLD HELLO'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">28</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello Selectëd #world Hello'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="changes-mixed-case-selection-to-all-lowercase">changes mixed case selection to all lowercase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello SelectËD #WorLd'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">22</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello selectëd #world'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="preserves-selection">preserves selection</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'select'</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">anchor</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">cursor</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(with no selection active)</span></h3>&#x000A;&#x000A;<h4 id="changes-all-lowercase-word-to-all-uppercase">changes all lowercase word to all uppercase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello wörld'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">7</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello WÖRLD'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="changes-all-uppercase-word-to-titlecase">changes all uppercase word to titlecase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello WÖRLD'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">7</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello Wörld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="changes-mixed-case-word-to-all-lowercase">changes mixed case word to all lowercase</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello WörLd'</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">7</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="o">\</span><span class="n">cycle_case</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'hello wörld'</span><span class="p">,</span><span class="w"> </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>&#x000A;</div>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2015
            <a class='alert-link' href='https://github.com/nilnor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
